package org.dromara.pay.jobhandler;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.pay.constant.TopUpConstant;
import org.dromara.pay.mapper.TopUpMapper;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 定时任务
 *
 * @author zlj
 * @since 2023/8/10
 */
// TODO: 如需要定时任务清理超时充值订单，请自行打开注释
@Slf4j
@Component
//@EnableScheduling
public class TopUpJobHandler {

    @Resource
    private TopUpMapper topUpMapper;

    /**
     * 清理超时充值订单
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void deleteOutTimeTopUp() {
        log.info("=========================开始清理超时充值订单=========================");
        int num = topUpMapper.deleteOutTimeTopUp(TopUpConstant.OUT_TIME);
        log.info("======================清理超时充值订单完毕,清理数量: " + num + "======================");
    }
}
